//
//  TKL_AuthDetailVC.m
//  TKL_EnPro
//
//  Created by 雅恩三河科技 on 2018/12/20.
//  Copyright © 2018年 MrZhang. All rights reserved.
//

//
//                .-~~~~~~~~~-._       _.-~~~~~~~~~-.
//            __.'              ~.   .~              `.__
//          .'//                  \./                  \\`.
//        .'//                     |                     \\`.
//      .'// .-~"""""""~~~~-._     |     _,-~~~~"""""""~-. \\`.
//    .'//.-"                 `-.  |  .-'                 "-.\\`.
//  .'//______.============-..   \ | /   ..-============.______\\`.
//.'______________________________\|/______________________________`.
//
//

#import "TKL_AuthDetailVC.h"

@interface TKL_AuthDetailVC ()<SDCycleScrollViewDelegate>
@property(nonatomic,strong)NSMutableDictionary* dataSource;
@property(nonatomic,strong)UIButton* btomBtn;
@end

@implementation TKL_AuthDetailVC
#pragma mark - getter and setter
-(UIButton *)btomBtn
{
    if (!_btomBtn)
    {
        @WeakSelf;
        _btomBtn = [[UIButton alloc]init];
        _btomBtn.width=WFCGFloatX(375);
        _btomBtn.height=WFCGFloatY(45);
        _btomBtn.x=WFCGFloatX(0);
        _btomBtn.y=SCREEN_HEIGHT-[self bottomShelterHeight]-WFCGFloatY(45);;
        [_btomBtn setEnlargeEdge:15];
        [_btomBtn setTitle:@"马上咨询" forState:UIControlStateNormal];
        [_btomBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [_btomBtn setBackgroundColor:Main_Color forState:UIControlStateNormal];
        _btomBtn.titleLabel.font = SYSTEMFONT(15);
        
        [_btomBtn handleControlEvent:UIControlEventTouchUpInside withBlock:^{
            [[GCPresenter shareInterface] phoneCall:@"400-088-1188"];
        }];
    }
    return _btomBtn;
}
-(NSMutableDictionary *)dataSource
{
    if (!_dataSource) {
        _dataSource=[NSMutableDictionary new];
    }
    return _dataSource;
}
#pragma mark - event
#pragma mark - method
-(void)initilization
{
    self.isGroup=YES;
    [self setNavgationTheme:2];
    self.navigationItem.title = @"";
    self.extendedLayoutIncludesOpaqueBars = YES;
    self.navigationController.navigationBar.shadowImage = [UIImage new];
    [self.view addSubview:self.baseTable];
    [self.view addSubview:self.btomBtn];
    
    self.baseTable.contentInset = UIEdgeInsetsMake(-1, 0, [self bottomShelterHeight]+WFCGFloatY(45), 0);
    [self.baseTable setSeparatorStyle:UITableViewCellSeparatorStyleNone];
    [self.baseTable setSeparatorColor: Main_Color_BG];
    [self.baseTable setBackgroundColor:Main_Color_BG];
    [self.baseTable setTintColor:Main_Color_BG];
    @WeakSelf;
    [self viewModelBand];
    [self reloadData];
}
-(void)viewModelBand
{
    @WeakSelf;
}
-(void)reloadData
{
    [self requestCityData];
}
#pragma mark - life
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
    //
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self initilization];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */
#pragma mark - delegate
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    if (section==1) {
        NSArray* arr=[self.dataSource objectForKey:@"photoImageClouds"];
        return arr.count;
    }
    return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    if (indexPath.section==0)
    {
        static NSString *CellID = @"CellID000011";
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellID];
        if (cell == nil) {
            cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellID];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
        }
        [cell.contentView removeAllSubviews];
        
        NSDictionary* myDic=[self.dataSource objectForKey:@"photographer"];
        UIImageView* coverIV=[UIImageView new];
        coverIV.width=WFCGFloatX(375);
        coverIV.height=WFCGFloatY(260);
        coverIV.x=WFCGFloatX(0);
        coverIV.y=WFCGFloatY(0);
        
        [coverIV sd_setImageWithURL:[NSURL URLWithString:[self.dataSource objectForKey:@"coverImgFileName4Works"]] placeholderImage:DefaultImage];
        [cell.contentView addSubview:coverIV];
        
        UIImageView* backView=[UIImageView new];
        backView.image=[UIImage imageNamed:@"au_bg_p"];
        backView.x=WFCGFloatX(0);
        backView.y=WFCGFloatY(120);
        backView.height=WFCGFloatY(200);
        backView.width=WFCGFloatX(375);
        [cell.contentView addSubview:backView];
        
        
        
        UIImageView* headIV=[UIImageView new];
        headIV.width=WFCGFloatY(70);
        headIV.height=WFCGFloatY(70);
        headIV.x=WFCGFloatX(30);
        headIV.y=WFCGFloatY(110);
        [WFFunctions WFUIaddbordertoView:headIV radius:WFCGFloatY(35) width:2 color:[UIColor whiteColor]];
        [headIV sd_setImageWithURL:[NSURL URLWithString:[myDic objectForKey:@"headImgFileName"]]];
        [cell.contentView addSubview:headIV];
        
        UILabel* titleLab=[UILabel new];
        titleLab.x=WFCGFloatX(20);
        titleLab.y=WFCGFloatY(190);
        titleLab.width=SCREEN_WIDTH-WFCGFloatX(40);
        titleLab.font=SYSTEMBOLDFONT(15);
        titleLab.textColor=HEXCOLOR(@"#333333");
        [cell.contentView addSubview:titleLab];
        titleLab.text=[myDic objectForKey:@"name"];
        titleLab.height=WFCGFloatY(18);
        
        UILabel* markLab=[UILabel new];
        markLab.x=WFCGFloatX(20);
        markLab.y=WFCGFloatY(215);
        markLab.width=SCREEN_WIDTH-WFCGFloatX(40);
        markLab.font=SYSTEMFONT(13);
        markLab.textColor=HEXCOLOR(@"#666666");
        [cell.contentView addSubview:markLab];
        markLab.text=[myDic objectForKey:@"description"];
        markLab.numberOfLines=2;
        markLab.height=WFCGFloatY(35);
        
        
        
        UILabel* moneyLab=[UILabel new];
        moneyLab.x=WFCGFloatX(20);
        moneyLab.y=WFCGFloatY(260);
        moneyLab.width=WFCGFloatX(100);
        moneyLab.font=SYSTEMFONT(15);
        moneyLab.textColor=Main_Color;
        [cell.contentView addSubview:moneyLab];//
        moneyLab.text=[NSString stringWithFormat:@"团队价格\n¥%@",[self.dataSource objectForKey:@"servicePrice"]];
        moneyLab.height=WFCGFloatY(50);
        moneyLab.numberOfLines=2;
        moneyLab.textAlignment=NSTextAlignmentCenter;
        
        NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:moneyLab.text];
        [string addAttribute:NSForegroundColorAttributeName value:HEXCOLOR(@"#333333") range:NSMakeRange(0, 4)];
        moneyLab.attributedText=string;
        
        
        NSArray* arrr=@[@"预约\n",@"作品\n",@"好评\n"];
        
        for (int i=0; i<3; i++)
        {
            
            UILabel* detailLab=[[UILabel alloc] init];
            detailLab.textAlignment = NSTextAlignmentLeft;
            
            detailLab.font = SYSTEMFONT(14);
            detailLab.textColor = Main_Color;
            detailLab.x=WFCGFloatX(165)+WFCGFloatX(70)*i;
            detailLab.y=WFCGFloatY(260);
            detailLab.width=WFCGFloatX(70);
            detailLab.height=WFCGFloatY(50);
            [cell.contentView addSubview:detailLab];
            detailLab.numberOfLines=2;
            detailLab.textAlignment=NSTextAlignmentCenter;
            if (i==0) {
                detailLab.text = [NSString stringWithFormat:@"%@%@",arrr[i],[self.dataSource objectForKey:@"followCount"]];
            }
            if (i==1) {
                detailLab.text = [NSString stringWithFormat:@"%@%@",arrr[i],[self.dataSource objectForKey:@"imageCloudCount"]];
            }
            if (i==2) {
                detailLab.text = [NSString stringWithFormat:@"%@%@",arrr[i],[self.dataSource objectForKey:@"commentCount"]];
            }
            
            NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:detailLab.text];
            [string addAttribute:NSForegroundColorAttributeName value:HEXCOLOR(@"#333333") range:NSMakeRange(0, 2)];
            detailLab.attributedText=string;
        }
        
        return cell;

    }
    
    
    static NSString *CellID = @"CellID";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellID];
    if (cell == nil) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.backgroundColor=[UIColor whiteColor];
    }
    [cell.contentView removeAllSubviews];
    
    
    NSArray* arr=[self.dataSource objectForKey:@"photoImageClouds"];
    NSDictionary* dic=[arr objectAtIndex:indexPath.row];
    NSInteger ww=[[dic objectForKey:@"width"] integerValue];
    NSInteger hh=[[dic objectForKey:@"height"] integerValue];;

    
    UIImageView* headIV=[UIImageView new];
    headIV.x=0;
    headIV.y=0;
    headIV.width=SCREEN_WIDTH;
    headIV.height=SCREEN_WIDTH*hh/ww;
    [headIV sd_setImageWithURL:[dic objectForKey:@"fileName"] placeholderImage:DefaultImage];
    
    [cell.contentView addSubview:headIV];
    return cell;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section==0)
    {
        return WFCGFloatY(320);
    }
    NSArray* arr=[self.dataSource objectForKey:@"photoImageClouds"];
    NSDictionary* dic=[arr objectAtIndex:indexPath.row];
    NSInteger ww=[[dic objectForKey:@"width"] integerValue];
    NSInteger hh=[[dic objectForKey:@"height"] integerValue];;

    return SCREEN_WIDTH*hh/ww+8;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    UIView* view=[UIView new];
    view.backgroundColor=[UIColor whiteColor];
    if (section!=0)
    {
        UILabel* titleLab=[UILabel new];
        titleLab.x=WFCGFloatX(0);
        titleLab.y=WFCGFloatY(0);
        titleLab.width=SCREEN_WIDTH;
        titleLab.font=SYSTEMFONT(16);
        titleLab.textColor=HEXCOLOR(@"#333333");
        [view addSubview:titleLab];
        titleLab.text=section==1?@"主要作品":@"线下体验店";
        titleLab.height=WFCGFloatY(50);
        titleLab.textAlignment=NSTextAlignmentCenter;
        
    }
    return view;
}
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    UIView* view=[UIView new];
    view.backgroundColor=Main_Color_BG;
    return view;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 5;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    if (section==0) {
        return .00001f;
    }
    return WFCGFloatY(50);
}
////http://101.201.171.131:8080/rest/api/user/detail/ 用户详情  userUuid=63e5eeec-588a-4c66-9356-ab7b4313a020
-(void)requestCityData
{
    @WeakSelf;
    NSMutableDictionary* para=[NSMutableDictionary new];
    //http://appserver.hunlimao.com/tripCity/14?device=iPhone&city=%E6%B5%8E%E5%8D%97&cid=53424&key=18765319560_HunLiMao_63afa4ddecb0478791a35471d5cd435f
    [para setObject:@"iPhone" forKey:@"device"];
    [para setObject:@"济南" forKey:@"city"];
    [para setObject:@"53424" forKey:@"cid"];
    //[para setObject:@"" forKey:@"key"];
    [para setObject:_passID forKey:@"id"];
    [[InterfaceManager shareInterface] requetInterface:@"get_auth_detail" withParameter:para handler:^(NSDictionary *info, InterfaceStatusModel *infoModel) {
        if (infoModel.errorCode ==0)
        {
            [self.dataSource removeAllObjects];
            self.dataSource=[[NSMutableDictionary alloc] initWithDictionary: info];
            
            [selfp.baseTable reloadData];
        }else
        {
            [FTIndicator showErrorWithMessage:infoModel.errorMsg];
        }
    }];;
}
@end


/*
 11111111111111111111111111111111111111001111111111111111111111111
 11111111111111111111111111111111111100011111111111111111111111111
 11111111111111111111111111111111100001111111111111111111111111111
 11111111111111111111111111111110000111111111111111111111111111111
 11111111111111111111111111111000000111111111111111111111111111111
 11111111111111111111111111100000011110001100000000000000011111111
 11111111111111111100000000000000000000000000000000011111111111111
 11111111111111110111000000000000000000000000000011111111111111111
 11111111111111111111111000000000000000000000000000000000111111111
 11111111111111111110000000000000000000000000000000111111111111111
 11111111111111111100011100000000000000000000000000000111111111111
 11111111111111100000110000000000011000000000000000000011111111111
 11111111111111000000000000000100111100000000000001100000111111111
 11111111110000000000000000001110111110000000000000111000011111111
 11111111000000000000000000011111111100000000000000011110001111111
 11111110000000011111111111111111111100000000000000001111100111111
 11111111000001111111111111111111110000000000000000001111111111111
 11111111110111111111111111111100000000000000000000000111111111111
 11111111111111110000000000000000000000000000000000000111111111111
 11111111111111111100000000000000000000000000001100000111111111111
 11111111111111000000000000000000000000000000111100000111111111111
 11111111111000000000000000000000000000000001111110000111111111111
 11111111100000000000000000000000000000001111111110000111111111111
 11111110000000000000000000000000000000111111111110000111111111111
 11111100000000000000000001110000001111111111111110001111111111111
 11111000000000000000011111111111111111111111111110011111111111111
 11110000000000000001111111111111111100111111111111111111111111111
 11100000000000000011111111111111111111100001111111111111111111111
 11100000000001000111111111111111111111111000001111111111111111111
 11000000000001100111111111111111111111111110000000111111111111111
 11000000000000111011111111111100011111000011100000001111111111111
 11000000000000011111111111111111000111110000000000000011111111111
 11000000000000000011111111111111000000000000000000000000111111111
 11001000000000000000001111111110000000000000000000000000001111111
 11100110000000000001111111110000000000000000111000000000000111111
 11110110000000000000000000000000000000000111111111110000000011111
 11111110000000000000000000000000000000001111111111111100000001111
 11111110000010000000000000000001100000000111011111111110000001111
 11111111000111110000000000000111110000000000111111111110110000111
 11111110001111111100010000000001111100000111111111111111110000111
 11111110001111111111111110000000111111100000000111111111111000111
 11111111001111111111111111111000000111111111111111111111111100011
 11111111101111111111111111111110000111111111111111111111111001111
 11111111111111111111111111111110001111111111111111111111100111111
 11111111111111111111111111111111001111111111111111111111001111111
 11111111111111111111111111111111100111111111111111111111111111111
 11111111111111111111111111111111110111111111111111111111111111111
 
 
 */
